package double_pointer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-12-02
 * Time: 17:04
 */
public class RemoveElement {
    public static int removeElement(int[] nums, int val) {
        int fast = 0;
        int low = -1;
        int count = 0;
        while (fast < nums.length) {
            if(nums[fast] != val) {
                nums[++low] = nums[fast];
                count++;
            }
            fast++;
        }
        return count;
    }

    public static void main(String[] args) {
        System.out.println(removeElement(new int[]{3, 2, 2, 3}, 3));
        System.out.println(1);
    }
}
